﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;
using StyleMVVM.DependencyInjection;

namespace StyleMVVM.MVC.Extensions
{
	[Export(typeof(IControllerActivator))]
	public class ControllerActivator : IControllerActivator
	{
		private IDependencyInjectionContainer container;

		[ImportConstructor]
		public ControllerActivator(IDependencyInjectionContainer container)
		{
			this.container = container;
		}

		public IController Create(RequestContext requestContext, Type controllerType)
		{
			return container.LocateByType(controllerType) as IController;
		}
	}
}